<?php

class DB_URL_ACCESS extends ORM_Table {
    static protected $table_name = 'url_access';
    
    static public function getTableName($params = null) {
        //$table_name = self::$table_name.substr($params['article_type_id'], 0, 1);
        return self::$table_name;
    }

    //更新统计操作
    static function setUpdate($uhash) {
        $ip     = getIp();
        $where  = array('ip' => $ip,'uhash' =>$uhash);
        $has    = ORM_Finder::findOne(DB_URL_ACCESS,"ip='$ip' and uhash='$uhash'");

        if(!$has) {
            $url    = new DB_URL_ACCESS();
            $url->setIp(getIp());
            $url->setUhash($uhash);
            $url->setCreated(time());
            $url->save();
        }else{
            $has->setVisit($has->getVisit()+1);
            $has->save();
        }
    }
}

